﻿using System;
using System.Diagnostics;
using System.Linq;
using System.Net.Http;
using System.Threading.Tasks;
using Google.Protobuf.WellKnownTypes;
using Grpc.Net.Client;
using GrpcCommon;

namespace GrpcGreeterClient
{
    class Program
    {
        static async Task Main(string[] args)
        {
            using var channel = GrpcChannel.ForAddress("https://localhost:7001");
            var client = new Greeter.GreeterClient(channel);

            var order = await client.GetOrderAsync(new OrderRequest { Id = "222", Time = Timestamp.FromDateTimeOffset(DateTime.Now) });
            Console.WriteLine($"我的订单是：{ order.Msg }，{order.Amount},{order.Remark}，销售数量-{order.Count ?? 0}");
            order.Names.ToList().ForEach(a => Console.WriteLine(a));
            order.Dic.Keys.ToList().ForEach(a => Console.WriteLine($"{a}:{order.Dic[a]}"));

            Console.ReadKey();
        }
    }
}